import { RulesEngine } from "../../core/rules/RulesEngine";

@RulesEngine.RegRule("TestRule")
class TestRule implements RulesEngine.IRule {
    evaluate(fact: RulesEngine.Fact<any>): boolean {
        const data = fact.value;
        return data.age >= 18;
    }
    execute(): void {
        throw new Error("Method not implemented.");
    }
}

class TestData {
    age: number = 1;
}

@RulesEngine.RegProxy("TestProxy")
class TestProxy implements RulesEngine.IProxy {
    name: string = "TestProxy";
    data: any;
    constructor() {
        this.data = new TestData();
        this.data.age = 18;
    }

    @RulesEngine.CheckRule("TestRule", "TestProxy")
    playGame() {
        console.log("我可以打游戏了！");
    }
}

function test_1() {
    const tp = new TestProxy();
    tp.playGame();
}

export function test_rulesengine() {
    console.log("===Test: test_rulesengine()");
    test_1();
}
